#include "pause_state.h"
#include "fsm.h"
#include "main_controller.h"
#include "masters/arm_controller.h"
using namespace std;
using namespace arm;
PauseState::PauseState()
{

}

/**
 * @brief PauseState::Update
 * @param fsm
 */
void PauseState::Update(FSM *fsm)
{
//	static int i=0;
//    cout<<i<<" :pause mode"<<endl;
    //cout<<slave_names_[fsm->arm_controller_->GetSlaveTargetIndex()]<<" PauseState::Update"<<endl;
    switch (fsm->arm_controller_->GetRunningStatus())
    {
    case main_controller::kRCStop:
        fsm->SetState(BaseState::kSleepState);
        break;
    case main_controller::kRCWorking:
    {
        char master_device=fsm->arm_controller_->GetMasterDeviceIndex();

        if(master_device>=0)
        {
            if(fsm->arm_controller_->GetConnectionStatus()==main_controller::kConnectionOkay)
            {
                fsm->SetState(BaseState::kResetState);
            }
        }
    }
        break;
    default:
        break;
    }
}

void PauseState::OnEntry(FSM *fsm)
{
    cout<<slave_names_[fsm->arm_controller_->GetSlaveTargetIndex()]<<" PauseState::OnEntry"<<endl;
    //drdStart(fsm->arm_controller_->GetMasterDeviceIndex());
    char master_device=fsm->arm_controller_->GetMasterDeviceIndex();

    if(master_device<0)
        return;
}

void PauseState::OnExit(FSM *fsm)
{

    cout<<slave_names_[fsm->arm_controller_->GetSlaveTargetIndex()]<<" PauseState::OnExit"<<endl;
}



